﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace spktNhom4DoAnCuoiKy
{
    public partial class UCUpDownNumberic : System.Web.UI.UserControl
    {
        double min = Double.MinValue, max = Double.MaxValue, step=1.0;
        public double Minimum
        {
            get { return min; }
            set { min = value; }
        }
        public double Maximum
        {
            get { return max; }
            set { max = value; }
        }
        public double Step
        {
            get { return step; }
            set { step = value; }
        }
        
        public string Width {
            get { return TextBox1.Width.ToString(); }
            set { TextBox1.Width = Unit.Parse(value); }
        }
        public string Height
        {
            get { return TextBox1.Height.ToString(); }
            set { TextBox1.Height = Unit.Parse(value); }
        }
      
        public string Text {
            get { return TextBox1.Text; }
            set { TextBox1.Text = value; }
        }
        //event

        public event EventHandler TextChanged;

        protected void Page_Load(object sender, EventArgs e)
        {
            string s = "";
        }

        protected void ButtonUp_Click(object sender, EventArgs e)
        {
            double current = -1;
            if (TextBox1.Text != "")
            {
               
                double.TryParse(TextBox1.Text, out current);
                if (current + step < max)
                TextBox1.Text = Math.Round(current+step, 3).ToString();
            }
        }

        protected void ButtonDown_Click(object sender, EventArgs e)
        {
            double current = -1;
            if (TextBox1.Text != "")
            {
                double.TryParse(TextBox1.Text, out current);
                if (current - step> min)
                TextBox1.Text = Math.Round(current-step, 3).ToString();
            }
        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            if (TextChanged != null)
            {
                TextChanged(sender, e);
            }
        }
    }
}